package com.kaibes.admin.permission;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.kaibes.web.admin.AdminMenu;
import com.kaibes.web.admin.AdminMenuRes;
import com.kaibes.web.thymeleaf.ThymeleafConfig;

@Configuration
public class PermissionInit implements InitializingBean {
    
    @Autowired
    private ThymeleafConfig webConfig;
    @Autowired
    private PowerUtils powerUtils;
    @Autowired
    private RoleUtils roleUtils;
    
    @Bean
    public AdminMenu roleManageMenu() {
        AdminMenu menu = new AdminMenu();
        menu.setKey("permission-roles");
        menu.setName("角色管理");
        menu.setIcon("fas fa-user-secret");
        menu.setHref("/admin/permission/role");
        menu.setSort(2);
        menu.setParentKey(AdminMenuRes.MENU_USER);
        return menu;
    }

	@Override
	public void afterPropertiesSet() throws Exception {
		webConfig.putStaticVariable("powerUtils", powerUtils);
        webConfig.putStaticVariable("roleUtils", roleUtils);
	}
    
}
